<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
namespace app\admin\controller;


/**
 * 我们的案例管理控制器
 */
class Product extends AdminBase
{
    public $categoryType = 
    [
            1=>"企业网站",
            2=>"H5微网站",
            3=>"电商商城",
            4=>"集团网站",
    ];
    
    
    /**
     * 企业网站
     */
    public function campanyWeb()
    {
        
        $this->commonList(1);
        
        return $this->fetch('campanyweb_list');
    }
    
    
    /**
     * 企业网站-添加
     */
    public function campanyAdd()
    {
        
        $this->ProductCommon(1,'campanyWeb');
        
        $this->assign('info', []);
        
        return $this->fetch('product_edit');
    }
    
    
    /**
     * 企业网站-编辑
     */
    public function campanyEdit()
    {
        
        $this->commonEdit(1,'campanyWeb');
        
        return $this->fetch('product_edit');
    }
    
    
    /**
     * H5微站
     */
    public function fiveWeb()
    {
        $this->commonList(2);
        
        return $this->fetch('fiveweb_list');
    }
    
    
     /**
     * 企业网站-添加
     */
    public function fiveAdd()
    {
        
        $this->ProductCommon(2,'fiveWeb');
        
        $this->assign('info', []);
        
        return $this->fetch('product_edit');
    }
    
    
    /**
     * 企业网站-编辑
     */
    public function fiveEdit()
    {
        
        $this->commonEdit(2,'fiveWeb');
        
        return $this->fetch('product_edit');
    }
    
    
    /**
     * 电商商城
     */
    public function elecShop()
    {
        $this->commonList(3);
        
        return $this->fetch('elecshop_list');
    }
    
    
         /**
     * 企业网站-添加
     */
    public function elecShopAdd()
    {
        
        $this->ProductCommon(3,'elecShop');
        
        $this->assign('info', []);
        
        return $this->fetch('product_edit');
    }
    
    
    /**
     * 企业网站-编辑
     */
    public function elecShopEdit()
    {
        
        $this->commonEdit(3,'elecShop');
        
        return $this->fetch('product_edit');
    }
    
    
    
    /**
     * 集团网站
     */
    public function groupWeb()
    {
        $this->commonList(4);
        
        return $this->fetch('group_list');
    }
    
    
         /**
     * 企业网站-添加
     */
    public function groupAdd()
    {
        
        $this->ProductCommon(4,'groupWeb');
        
        $this->assign('info', []);
        
        return $this->fetch('product_edit');
    }
    
    
    /**
     * 企业网站-编辑
     */
    public function groupEdit()
    {
        
        $this->commonEdit(4,'groupWeb');
        
        return $this->fetch('product_edit');
    }
    
    
    
    /**
     * 案例列表通用方法
     * @param type $type 案例类型
     * @return type
     */
    public function commonList($type)
    {    
        $where['category_id'] = $type;
        
        $this->assign('list', $this->logicProduct->getProductList($where,'*','sort'));
        
        return $this->fetch('product_list');
    }
   
    
    /**
     * 通用编辑方法
     */
    public function commonEdit($type,$url)
    {         
        $this->ProductCommon($type,$url);
        
        $info = $this->logicProduct->getProductInfo(['a.id' => $this->param['id']]);
 
        $this->assign('info', $info);
    }
    
    /**
     * 更改业绩状态
     */
    public function setStatus()
    {
        
       $this->jump($this->logicAdminBase->setStatus('Product', $this->param));
    }


    /**
     * 我们的案例添加与编辑通用方法
     */
    public function ProductCommon($type,$url)
    {
        
        IS_POST && $this->jump($this->logicProduct->ProductEdit($this->param,$type,$url));//判断是否表单提交 是则跳转保存处理
    }
    
    /**
     * 排序
     */
    public function setSort()
    {
        
        $this->jump($this->logicAdminBase->setSort('Product', $this->param));
    }
}
